package thread.mianshi;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicInteger;

public class Test implements Runnable {


   // AtomicInteger atomicInteger = new AtomicInteger(0);
    static int i = 0;
    public static void main(String[] args) throws InterruptedException {
        Test test = new Test();
        Thread thread1 = new Thread(test,"test1");
        Thread thread2 = new Thread(test,"test2");
        Thread thread3 = new Thread(test,"test3");

        thread1.start();
        thread2.start();
        thread3.start();
        Thread.sleep(1000);
    }

    @Override
    public void run() {
       // System.out.printf("当前线程%s获取序列号:%s\n",Thread.currentThread().getName(),new SimpleDateFormat("yyyyMMddHHmmsss").format(new Date())+atomicInteger.incrementAndGet());
      //  System.out.printf("当前线程%s获取序列号:%s\n",Thread.currentThread().getName(),UUID.randomUUID().toString());
        synchronized (Object.class){
              System.out.printf("当前线程%s获取序列号:%s\n",Thread.currentThread().getName(),new SimpleDateFormat("yyyyMMddHHmmsss").format(new Date())+(i++));

        }
    }
}
